package cn.eeepay.boss.system;

import cn.eeepay.framework.model.UserLoginInfo;
import org.springframework.security.core.context.SecurityContextHolder;

/**
 * 公用工具抽象类
 * @author DJ
 * @date 2020年09月27日上午09:08:04
 */
public abstract class CommonUtilAbstract {

	/**
	 * 获取登录用户关联的销售人员（用于过滤一级代理商的销售人员）
	 * @return
	 */
    public static String getSaleNames() {
		Object principalObj = null;
		String saleNames = null;
		try {
			principalObj = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
			if(principalObj instanceof UserLoginInfo) {
				final UserLoginInfo principal = (UserLoginInfo) principalObj;
				saleNames = principal.getExtended(CommonConst.saleNames);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return saleNames;
	}
}
